﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using web.data.entities;
using web.bussines;
using Webdiyer.WebControls.Mvc;
using System.Web.UI;
using web.core.Controllers;

namespace web.core.Models
{
    public class pageStaticModels
    {
        //get all get all
        public static PagedList<page_static> adm_page_static_list(int pageindex, int pagesize, int language_id)
        {
            var obj = new page_static_service();
            return obj.adm_page_static_list(pageindex, pagesize, language_id);
        }

        public static List<page_static> page_static_list_by_status(bool isshow,bool onmenu,  int language_id)
        {
            var obj = new page_static_service();
            return obj.page_static_list_by_status(isshow, onmenu, language_id);
        }

        public static int adm_page_static_update(page_static it)
        {
            var obj = new page_static_service();
            return obj.adm_page_static_update(it);
        }

        //enable - disable  
        public static int adm_page_statis_enable(int page_id, bool is_show)
        {
            var obj = new page_static_service();
            return obj.adm_page_statis_enable(page_id, is_show);
        }

        //cap nhat trang thai hien thi tren menu hoac ko
        public static int adm_page_statis_on_menu(int page_id, bool on_menu)
        {
            var obj = new page_static_service();
            return obj.adm_page_statis_on_menu(page_id, on_menu);
        }

        //get items by id  
        public static page_static getByID(int id)
        {
            var obj = new page_static_service();
            return obj.getByID(id);
        }
         //delete by id
        public static void deletePage(int id) {
            var obj = new page_static_service();
            //delete all images
            var item = getByID(id);
            if (item != null)
            {
                if (!string.IsNullOrEmpty(item.image_path))
                    baseController.DeleteFile(item.image_path);
            }
            //delete record in db
            obj.deletePage(id);
        }
    }
}